import React from 'react';
import { Redirect,  Switch,Route } from 'react-router-dom';
let login =React.lazy(()=>import ("./pages/login/login"))
let register =React.lazy(()=>import ("./pages/register/register"))
let index =React.lazy(()=>import ("./pages/index/index"))
let detail =React.lazy(()=>import("./pages/detail/detail"))
let mine =React.lazy(()=>import("./pages/mine/mine"))


const App = () => {
  return (
    <React.Suspense fallback={<div>loadding...</div>}>
      {/* 路由出口 */}
      <Switch>
        {/* 路由规则 */}
      <Route path="/login" component={login}></Route>
      <Route path="/index" component={index}></Route>
      <Route path="/register" component={register}></Route>
      <Route path="/detail/:id" component={detail}></Route>
      <Route path="/mine" component={mine}></Route>

      {/* 重定向 */}
      <Redirect to="/login"></Redirect>
      </Switch>
    </React.Suspense>
  );
}

export default App;